<?php
header('Content-type:text/html;charset=utf-8');

//开启session
session_start();

//包含数据库配置
include '../public/peizhi.php';

//包含函数库
include '../public/func.php';

//调用函数连接数据库
$link = db();

//接值板块ID
$bk_id = $_POST['bk_id'];

//接值表单
$tz_id = $_POST['tz_id'];

$ht_content = $_POST['ht_content'];

//判断用户是否登录
if(!isset($_SESSION['uid'])){
	exit("<script>alert('用户未登录');window.location.href='./php/xiangqing.php?bk_id={$bk_id}&tz_id={$tz_id}';</script>");
}

$uid = $_SESSION['uid'];

//接值验证码
/* $yanzheng = strtolower($_POST['yanzheng']);
$yzm = strtolower($_SESSION['yzm']); */

//获取当前时间
$time = time();

//判断验证码是否一致
/* if($yanzheng != $yzm){
	exit("<script>alert('验证码错误');window.location.href='./php/xiangqing.php?bk_id={$bk_id}&tz_id={$tz_id}';</script>");
} */

//存入数据库
$sql = "insert into huitie(u_id,ft_id,ht_content,ht_time) values('{$uid}','{$tz_id}','{$ht_content}','{$time}')";

//判断跳转
if($res = mysqli_query($link,$sql)){
	echo "<script>alert('回帖成功');window.location.href='./php/xiangqing.php?bk_id={$bk_id}&tz_id={$tz_id}';</script>";
}else{
	echo "<script>alert('回帖失败');window.location.href='./php/xiangqing.php?bk_id={$bk_id}&tz_id={$tz_id}';</script>";
}






